CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1
CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-g++-4.0.1
LD=$(CC)

SDKVER=2.0
SDK=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(SDKVER).sdk

LICENSE=LICENSED
LDFLAGS= -framework Foundation \
        -framework UIKit \
        -framework CoreFoundation \
        -framework CoreGraphics \
        -framework Preferences \
        -framework GraphicsServices \
        -L$(SDK)/usr/lib \
        -F$(SDK)/System/Library/Frameworks \
        -F$(SDK)/System/Library/PrivateFrameworks \
        -lsubstrate \
        -lobjc

CFLAGS= -I$(SDK)/var/include \
  -I/var/include \
  -I/var/include/gcc/darwin/4.0 \
  -I"$(SDK)/usr/include" \
  -I"/Developer/Platforms/iPhoneOS.platform/Developer/usr/include" \
  -I"/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin9/4.0.1/include" \
  -DDEBUG -Diphoneos_version_min=2.0

Name=ReflectiveDock

all:	package

$(Name).dylib:	$(Name).o
		$(LD) $(LDFLAGS) -dynamiclib -init _ReflectiveDockInitialize -o $@ $^
		ldid -S $(Target)

%.o:	%.mm
		$(CPP) -c $(CFLAGS) $< -o $@

clean:
		rm -f *.o $(Target)
		rm -rf package

package:	$(Name).dylib
	mkdir -p package/DEBIAN
	cp control package/DEBIAN
	mkdir -p package/Library/MobileSubstrate/DynamicLibraries
	cp $(Name).dylib package/Library/MobileSubstrate/DynamicLibraries
	cp $(Name).plist package/Library/MobileSubstrate/DynamicLibraries
	mkdir -p package/Library/PreferenceLoader/Preferences
	cp Preferences/* package/Library/PreferenceLoader/Preferences/
	dpkg-deb -b package $(Name)_$(shell grep ^Version: control | cut -d ' ' -f 2).deb

